class BeautyController < ApplicationController
  def index
  	@beauty_items = BeautyItem.all
  	@area = [ "粤", "京", "津", "沪", "渝", "冀", "豫", "云", "辽", "黑", "湘", "皖", "鲁", "新", "苏", "浙", "赣", "桂", "甘", "晋", "蒙", "陕", "吉", "闽", "贵", "青", "藏", "琼"]
    @letter = [ "S", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "Z"]
    if params.has_key? :save
      @order_beauty = OrderBeauty.create(car_num: params[:n1]+params[:n2]+params[:n3], phone: params[:phone])
      params.each do |k|
	      if k[0].split("_")[0] == 'item'
	        @key = k[0].split("_")[0]
	        @ndx = k[0].split("_")[1]
	        @val = k[1]
	        @order_beauty.order_beauty_details.create(beauty_item_id: @val)
	      end
	  end
      @order_beauty.update_total
      redirect_to '/beauty/show'
    end
  end

  def show
    @order_beauty = OrderBeauty.last
    if params.has_key? :no
      @order_beauty.destroy
      redirect_to '/beauty/index'
    elsif params.has_key? :yes
      redirect_to '/beauty/pay'
    end
  end

  def pay

  end
end
